home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-01-17 | 1.4 KB | 63 lines | [TEXT/PJMM] |
- unit AnimatedCursor;
-
- interface
-
- type
- acurState = record
- which_acur, nextFrame: INTEGER;
- nextTime: LONGINT;
- end;
-
- procedure Init_acur (theID: INTEGER; var theVars: acurState);
- procedure Animate_acur (var theVars: acurState);
-
- implementation
-
- procedure Init_acur (theID: INTEGER; var theVars: acurState);
- begin
- with theVars do
- begin
- which_acur := theID;
- nextFrame := 1;
- nextTime := TickCount;
- end;
- end; { Init_acur }
-
- procedure Animate_acur (var theVars: acurState);
- const
- minTicks = 2; {Never change frames faster than this}
- type
- acur = record
- frames, ticks: INTEGER;
- CURS_ids: array[1..1] of record
- num, fill: INTEGER
- end;
- end;
- acurPtr = ^acur;
- acurHandle = ^acurPtr;
- var
- the_acur: acurHandle;
- begin
- with theVars do
- begin
- the_acur := acurHandle(GetResource('acur', which_acur));
- if TickCount >= nextTime then
- with the_acur^^ do
- begin
- HLock(Handle(the_acur));
- if (nextFrame < 1) or (nextFrame > frames) then
- nextFrame := 1;
- {$PUSH}
- {$R-}
- SetCursor(GetCursor(CURS_ids[nextFrame].num)^^);
- {$POP}
- nextFrame := nextFrame + 1;
- nextTime := nextTime + ticks;
- if TickCount >= nextTime then {We're playing catch-up, or the acur resource is "hyperkinetic"}
- nextTime := TickCount + 2;
- HUnlock(Handle(the_acur));
- end;
- end;
- end; { Animate_acur }
-
- end.